package model

import "gorm.io/gorm"

type User struct {
	gorm.Model
	Username string `gorm:"type:varchar(150);not null;commit:'用户名'"`
	Password string `gorm:"type:char(32);not null;commit:'密码'"`
	Email    string `gorm:"type:varchar(60);not null;commit:'邮箱'"`
	Status   int64  `gorm:"type:int;default:0;not null;commit:'状态:0-正常,1-异常'"`
}

func (u *User) GetUsernameBUsername(db *gorm.DB, username string) error {
	err := db.Where("username=?", username).Find(&u).Error
	return err
}
func (u *User) CreateUser(db *gorm.DB) error {
	err := db.Create(&u).Error
	return err
}
